//
// Created by Administrator on 2021/3/1.
//

#include "operation.h"

double OperationApply(Operation *operation){
  if(operation->operator){
    return operation->operator(operation->left, operation->right);
  }else {
    return 0.0;
  }
}

double Plus(double left, double right){
  return left + right;
}
double Minus(double left, double right){
  return left - right;
}
double Multiply(double left, double right){
  return left * right;
}
double Divide(double left, double right){
  if (right == 0.0) { //当前场景下 用户输入的0一定就是这个0.0, float的精度问题只存在于计算时
    return 0;
  }else {
    return left / right;
  }
}
